package com.iplant.basic.serviceImpl.dao.bpm;

import com.iplant.base.po.OutResult;
import com.iplant.base.po.ServiceResult;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.general.StringUtils;
import com.iplant.base.utils.sql.BaseDAO;
import com.iplant.basic.service.po.bms.BMSEmployee;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 班组管理
 *
 * @author YouWang·Peng
 * 2023-8-8 15:54:17
 */
public class BPMUserDAO extends BaseDAO {
    private static BPMUserDAO Instance = null;

    private static Logger logger = LoggerFactory.getLogger(BPMUserDAO.class);

    private BPMUserDAO() {
        super();
    }

    public static BPMUserDAO getInstance() {
        if (Instance == null)
            Instance = new BPMUserDAO();
        return Instance;
    }

    /**
     * 清空用户组数据
     */
    public void TruncateGroup(BMSEmployee wLoginUser, OutResult<Integer> wErrorCode) {
        try {
            String wSQL = StringUtils.Format("truncate table {0}.act_id_membership;",
                    DBSchemas.BPM.getDBName());

            Map<String, Object> wParamMap = new HashMap<String, Object>();

            wSQL = this.DMLChange(wSQL);

            this.update(wSQL, wParamMap);
        } catch (Exception ex) {
            logger.error(ex.toString());
        }
    }

    /**
     * 清空用户数据
     */
    public void TruncateUser(BMSEmployee wLoginUser, OutResult<Integer> wErrorCode) {
        try {
            String wSQL = StringUtils.Format("truncate table {0}.act_id_user;",
                    DBSchemas.BPM.getDBName());

            Map<String, Object> wParamMap = new HashMap<String, Object>();

            wSQL = this.DMLChange(wSQL);

            this.update(wSQL, wParamMap);
        } catch (Exception ex) {
            logger.error(ex.toString());
        }
    }
}
